﻿//-----------------------------------------------------------------------
// <copyright file="DataManager.cs" company="Streetlight Technologies L.L.C.">
//    Copyright Streetlight Technologies L.L.C. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Streetlight.Store.DataAccess
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Streetlight.Store.Contracts;

    /// <summary>
    /// Implements ITransactionManager using the Entity Framework.
    /// </summary>
    public class DataManager : ITransactionManager
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DataManager"/> class.
        /// </summary>
        public DataManager()
        {
            Context = new DataModels.StoreEntities();

            Products = new ProductDataManager(this);
        }

        /// <summary>
        /// Gets and instance of IProductManager to perform Product data transactions.
        /// </summary>
        public IProductManager Products { get; private set; }

        /// <summary>
        /// Gets an instance of StoreEntities used to manage database transactions.
        /// </summary>
        internal DataModels.StoreEntities Context { get; private set; }

        /// <summary>
        /// Disposes the Context instance.
        /// </summary>
        public void Dispose()
        {
            Context.Dispose();
        }
    }
}
